/**
 * Copyright (C), 2024, xxxx有限公司
 * FileName: ToolsExtends
 * Author:   TLVM
 * Date:     3/23/2024 12:14 PM
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.iqcctt.simpleflow.typeengine.example;

import java.lang.reflect.Field;

/**
 * 〈一句话功能简述〉<br>
 * 〈〉
 *
 * @author TLVM
 * @create 3/23/2024
 * @since 1.0.0
 */
public class ToolsExtends {
    public static Object getValue(Object object, String fieldName) {
        try {

            Field field = object.getClass().getDeclaredField(fieldName);
            field.setAccessible(true);
            return field.get(object);
        } catch (NoSuchFieldException e) {

        } catch (IllegalAccessException e) {

        }
        return null;
    }

    public static Field getField(Object object, String fieldName) {
        try {
            Field field = object.getClass().getDeclaredField(fieldName);
            field.setAccessible(true);
            return field;
        } catch (NoSuchFieldException e) {

        }
        return null;
    }

    public static void setFieldValue(Object object, String fieldNam,Object value) throws NoSuchFieldException, IllegalAccessException {
        Field field = object.getClass().getDeclaredField(fieldNam);
        field.setAccessible(true);
        field.set(object,value);
    }
}
